package io.byte_stream;

import java.io.*;

public class Test1 {//加密
    public static void main(String[] args) throws IOException {
        BufferedInputStream bis = new BufferedInputStream(new FileInputStream("D:\\wangdao_study\\studyHard\\添狗.txt"));
        BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream("舔狗_copy.txt"));

        int len;

        while ((len = bis.read()) != -1) {
            bos.write(len ^ 123);
            // 一个数对同一个数疑惑两次就是同一个数，所以:^123 就是秘钥
            //加密
        }

        //关流
        bis.close();
        bos.close();
    }
}
class Test2 { //解密
    public static void main(String[] args) throws IOException {
        BufferedInputStream bis = new BufferedInputStream(new FileInputStream("舔狗_copy.txt"));
        BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream("舔狗_copy_解密.txt"));

        int len;
        while((len = bis.read()) != -1) {
            //文件解密
            bos.write(len ^ 123);
        }

        //关流
        bis.close();
        bos.close();


    }
}


